class Solution(object):
    def subtractProductAndSum(self, n):
        """
        :type n: int
        :rtype: int
        """
        n = str(n)
        n = [int(i) for i in n]
        n_sum = sum(n)
        n_dot = 1
        for i in n:
            n_dot *= i
        return n_dot - n_sum
    
if __name__ == '__main__':
    n = 4421
    print(Solution().subtractProductAndSum(n))